﻿// Run the script on DOM ready:
$(function () {

    var addselectCar = $(".selectCar");
    $.post("/CarInfo/GetCarNumberList", {},
            function (data) {
                addselectCar.empty();
                addselectCar.append('<option value="AllCar">公司所有车辆</option>');
                $.each(data, function () {
                    addselectCar.append('<option>' + this + '</option>');
                });
                var splitUrl = window.location.href.split("&");
                var curUrlCar = splitUrl[1].split("=");
                addselectCar.val(decodeURI(curUrlCar[1]));
            });

    var addSelectYear = $(".selectYear");
    addSelectYear.empty();
    for (var year = 1999; year <= 2050; year++) {
        addSelectYear.append('<option>' + year + '</option>');
    }

    splitUrl = window.location.href.split("=");
    var curUrlYear = splitUrl[1].split("&");
    addSelectYear.val(curUrlYear[0]);


    var selectReport = $(".selectReport").val();
    if (selectReport == "AllQuarterCost") {
        $('table').visualize({ type: 'pie', height: '199px', width: '420px' });
        $('table').visualize({ type: 'line', width: '420px' });
    }

    $('table').visualize({ type: 'bar', width: '420px' });

    $('table').visualize({ type: 'area', width: '420px' });

    $(".checkReport").click(function () {

        var selectReport = $(".selectReport").val();
        var selectYear = $(".selectYear").val();
        var selectCar = $(".selectCar").val();
        var reportUrl = "../../QuarterCost/" + selectReport;
        window.location.href = reportUrl + "?id=" + selectYear + "&carNumber=" + selectCar;

    })
});